package syfer;

import java.awt.Font;
import javafx.ext.swing.SwingComponent;
import javax.swing.JComponent;
import javax.swing.JTextArea;
import javax.swing.border.LineBorder;
import java.awt.Color;
import javax.swing.JScrollPane;

public class TextArea extends SwingComponent {

    var cmp: JTextArea;
    public var length: Integer;
    public var readText: String;
    public var text: String on replace {
        cmp.setText(text);
    }

    public var x: Integer on replace{
        translateX = x;
    }

    public var y: Integer on replace{
        translateY = y;
    }

    public var rows: Integer on replace{
        cmp.setRows(rows);
    }

    public var cols: Integer on replace{
        cmp.setColumns(cols);
    }

    public override function createJComponent(): JComponent {
        var f: Font = new Font("sanserif", Font.PLAIN, 11);
        cmp = new JTextArea();
        cmp.setFont(f);
        cmp.setEditable(false);
        cmp.setLineWrap(true);
        cmp.setBorder(new LineBorder(Color.gray));

        return new JScrollPane(cmp, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    }
}



